
import 'dart:math';

import 'package:flutter/material.dart';

class AlignTest extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Center(
      child: new Container(
        height: 120.0,
        width: 120.0,
        color: Colors.blue[50],
        child: Align(
          alignment: Alignment.center,
          child: FlutterLogo(
            size: 60,
          ),
        ),
      ),
    );
  }
}

class AlignTest2 extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Center(
      child: new Container(
        height: 120.0,
        width: 120.0,
        color: Colors.blue[50],
        child: Align(
          //默认中心为原点
          alignment: Alignment(-1, 1),
          child: FlutterLogo(
            size: 60,
          ),
        ),
      ),
    );
  }
}

class AlignTest3 extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Center(
      child: new Container(
        height: 120.0,
        width: 120.0,
        color: Colors.blue[50],
        child: Align(
          //左上角为原点
          alignment: FractionalOffset(0.1, 0.5),
          child: FlutterLogo(
            size: 60,
          ),
        ),
      ),
    );
  }
}

class FitBoxTest extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Center(
      child: new Container(
        height: 200.0,
        width: 200.0,
        color: Colors.blue[50],
        child: FittedBox(
          fit: BoxFit.contain,
          alignment: Alignment.center,
          child: Container(
            child: new Text('txt', style: new TextStyle(fontSize: 12.0, color: Colors.white),),
            decoration: BoxDecoration(
              color: Colors.blue[900]
            ),
          ),
        ),
      ),
    );
  }
}

class AspectRatioTest extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Center(
      child: new Container(
        height: 200.0,
        color: Colors.blue[50],
        child: AspectRatio(
          aspectRatio: 1 / 2,
          child: Container(
              color: Colors.blue[900]
          ),
        ),
      ),
    );
  }
}

class ConstraintBoxTest extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Center(
      child: new Container(
        width: 200.0,
        height: 200.0,
        color: Colors.blue[50],
        child: ConstrainedBox(
          //BoxConstraints.expand扩展占用所有空间
          constraints: new BoxConstraints(
            maxWidth: 100,
            maxHeight: 100,
          ),
          child: Container(
            width: 50,
            height: 10,
              color: Colors.red[900]
          ),
        ),
      ),
    );
  }
}

class TransformTest extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return new Container(
        color: Colors.blue[50],
        child: Transform(
          alignment: Alignment.topRight,
          transform: Matrix4.skewY(0.2)..rotateZ(- pi/11.0),
          child: Container(
            padding: const EdgeInsets.all(8.0),
            color: const Color(0xFFE8581C),
            child: const Text('Apartment for rent!'),
          ),
        )
    );
  }
}

class SlidebarTest extends StatelessWidget {

  num progress;

  @override
  Widget build(BuildContext context) {
    return new Container(
        color: Colors.blue[50],
        child: Slider.adaptive(
          value: 5,
          min: 0,
          max: 100,
          onChanged: (v){
            progress = v;
          },
          label: progress.toString(),
        )
    );
  }
}
